package com.onemore.task.model;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.voovan.tools.log.Logger;

import com.alibaba.fastjson.JSONObject;
import com.onemore.task.JdbcGlobal;

public class ModelJordermx extends JdbcGlobal{

	public final static String jordermx_field[] = new String[] {"DJBH","MIBH","MXBH",
    		"SPDM","GG1DM",
    		"GG2DM","SL","SL_1","SL_2","CKJ","ZK","DJ","DJ_1","DJ_2","DJ_3","JE","HH",
    		"BZ","BYZD1","BYZD6","BYZD8","BYZD9","BYZD10","BYZD11","BYZD12","BYZD13"};
	static public boolean insert(JSONObject json) throws SQLException
    {
		String fieldStr = "";
    	String valuesStr = "";
    	List<String> listFields = new ArrayList<String>();

    	int i = 0;
    	for(i=0;i<jordermx_field.length;i++) {
    		if(json.containsKey(jordermx_field[i]))
    			listFields.add(jordermx_field[i]);
    	}
    	for(i=0;i<listFields.size()-1;i++) {
    		fieldStr += listFields.get(i)+",";
    		valuesStr += "'"+json.getString(listFields.get(i))+"',";
    	}
		fieldStr += listFields.get(i);
		valuesStr += "'"+json.getString(listFields.get(i))+"'";
		//delete("JORDERMX",jordermx_field[0]+"='"+json.getString(jordermx_field[0])+"'");
    	String sql = "";
        //查询测试
        sql = "insert into JORDERMX ("+fieldStr+") values("+valuesStr+")";
        Map<String, Object> map = null;
		Logger.debug(sql);
		getJdbcOperate().update(sql);
		return true;
    }
}
